﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.5
// Code is generated on: Monday, December 17, 2012 11:21:26 AM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using WHMS;
using WHMS.FactoryClasses;
using WHMS.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace WHMS.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: WithdrawRequest. </summary>
	public partial class WithdrawRequestRelations
	{
		/// <summary>CTor</summary>
		public WithdrawRequestRelations()
		{
		}

		/// <summary>Gets all relations of the WithdrawRequestEntity as a list of IEntityRelation objects.</summary>
		/// <returns>a list of IEntityRelation objects</returns>
		public virtual List<IEntityRelation> GetAllRelations()
		{
			List<IEntityRelation> toReturn = new List<IEntityRelation>();
			toReturn.Add(this.WithdrawRequestItemEntityUsingWithdrawRequestId);
			toReturn.Add(this.ContractorEntityUsingContractorId);
			toReturn.Add(this.ProjectEntityUsingProjectId);
			toReturn.Add(this.UserEntityUsingAccountantId);
			toReturn.Add(this.UserEntityUsingCreatedBy);
			toReturn.Add(this.WithdrawalTypeEntityUsingWithdrawalTypeId);
			return toReturn;
		}

		#region Class Property Declarations

		/// <summary>Returns a new IEntityRelation object, between WithdrawRequestEntity and WithdrawRequestItemEntity over the 1:n relation they have, using the relation between the fields:
		/// WithdrawRequest.Id - WithdrawRequestItem.WithdrawRequestId
		/// </summary>
		public virtual IEntityRelation WithdrawRequestItemEntityUsingWithdrawRequestId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "WithdrawRequestItems" , true);
				relation.AddEntityFieldPair(WithdrawRequestFields.Id, WithdrawRequestItemFields.WithdrawRequestId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestItemEntity", false);
				return relation;
			}
		}


		/// <summary>Returns a new IEntityRelation object, between WithdrawRequestEntity and ContractorEntity over the m:1 relation they have, using the relation between the fields:
		/// WithdrawRequest.ContractorId - Contractor.Id
		/// </summary>
		public virtual IEntityRelation ContractorEntityUsingContractorId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Contractor", false);
				relation.AddEntityFieldPair(ContractorFields.Id, WithdrawRequestFields.ContractorId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ContractorEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between WithdrawRequestEntity and ProjectEntity over the m:1 relation they have, using the relation between the fields:
		/// WithdrawRequest.ProjectId - Project.Id
		/// </summary>
		public virtual IEntityRelation ProjectEntityUsingProjectId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Project", false);
				relation.AddEntityFieldPair(ProjectFields.Id, WithdrawRequestFields.ProjectId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProjectEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between WithdrawRequestEntity and UserEntity over the m:1 relation they have, using the relation between the fields:
		/// WithdrawRequest.AccountantId - User.Id
		/// </summary>
		public virtual IEntityRelation UserEntityUsingAccountantId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "User", false);
				relation.AddEntityFieldPair(UserFields.Id, WithdrawRequestFields.AccountantId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between WithdrawRequestEntity and UserEntity over the m:1 relation they have, using the relation between the fields:
		/// WithdrawRequest.CreatedBy - User.Id
		/// </summary>
		public virtual IEntityRelation UserEntityUsingCreatedBy
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "User_", false);
				relation.AddEntityFieldPair(UserFields.Id, WithdrawRequestFields.CreatedBy);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between WithdrawRequestEntity and WithdrawalTypeEntity over the m:1 relation they have, using the relation between the fields:
		/// WithdrawRequest.WithdrawalTypeId - WithdrawalType.Id
		/// </summary>
		public virtual IEntityRelation WithdrawalTypeEntityUsingWithdrawalTypeId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "WithdrawalType", false);
				relation.AddEntityFieldPair(WithdrawalTypeFields.Id, WithdrawRequestFields.WithdrawalTypeId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawalTypeEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", true);
				return relation;
			}
		}
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSubTypeRelation(string subTypeEntityName) { return null; }
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSuperTypeRelation() { return null;}
		#endregion

		#region Included Code

		#endregion
	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticWithdrawRequestRelations
	{
		internal static readonly IEntityRelation WithdrawRequestItemEntityUsingWithdrawRequestIdStatic = new WithdrawRequestRelations().WithdrawRequestItemEntityUsingWithdrawRequestId;
		internal static readonly IEntityRelation ContractorEntityUsingContractorIdStatic = new WithdrawRequestRelations().ContractorEntityUsingContractorId;
		internal static readonly IEntityRelation ProjectEntityUsingProjectIdStatic = new WithdrawRequestRelations().ProjectEntityUsingProjectId;
		internal static readonly IEntityRelation UserEntityUsingAccountantIdStatic = new WithdrawRequestRelations().UserEntityUsingAccountantId;
		internal static readonly IEntityRelation UserEntityUsingCreatedByStatic = new WithdrawRequestRelations().UserEntityUsingCreatedBy;
		internal static readonly IEntityRelation WithdrawalTypeEntityUsingWithdrawalTypeIdStatic = new WithdrawRequestRelations().WithdrawalTypeEntityUsingWithdrawalTypeId;

		/// <summary>CTor</summary>
		static StaticWithdrawRequestRelations()
		{
		}
	}
}
